{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Daily Summaries for the Last Seven Days"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import datetime\n",
    "from IPython.display import display, Markdown\n",
    "import snakemd\n",
    "\n",
    "from garmindb import GarminConnectConfigManager\n",
    "from garmindb.garmindb import GarminSummaryDb, DaysSummary\n",
    "\n",
    "from jupyter_funcs import format_number\n",
    "from graphs import Graph\n",
    "\n",
    "\n",
    "def __render_day(garmin_sum_db, graph, date):\n",
    "    day = DaysSummary.get_day(garmin_sum_db, date)\n",
    "    if day:\n",
    "        doc = snakemd.new_doc()\n",
    "        doc.add_heading(f\"Summary of {date}\")\n",
    "        doc.add_table(['Weight', 'Resting HR', 'Max HR', 'Waking Avg RR', 'Steps', 'Floors', 'Intensity Mins', 'Calories', 'Sleep', 'REM Sleep', 'Stress'],\n",
    "            [\n",
    "                [format_number(day.weight_avg), day.rhr_avg, day.hr_max, day.rr_waking_avg, day.steps, format_number(day.floors, 1),\n",
    "                 day.intensity_time, day.calories_avg, day.sleep_avg, day.rem_sleep_avg, day.stress_avg]\n",
    "            ]\n",
    "        )\n",
    "        display(Markdown(str(doc)))\n",
    "    graph.graph_date(date)\n",
    "\n",
    "\n",
    "gc_config = GarminConnectConfigManager()\n",
    "db_params_dict = gc_config.get_db_params()\n",
    "garmin_sum_db = GarminSummaryDb(db_params_dict)\n",
    "\n",
    "graph = Graph()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "__render_day(garmin_sum_db, graph, datetime.date.today() - datetime.timedelta(days = 1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "__render_day(garmin_sum_db, graph, datetime.date.today() - datetime.timedelta(days = 2))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "__render_day(garmin_sum_db, graph, datetime.date.today() - datetime.timedelta(days = 3))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "__render_day(garmin_sum_db, graph, datetime.date.today() - datetime.timedelta(days = 4))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "__render_day(garmin_sum_db, graph, datetime.date.today() - datetime.timedelta(days = 5))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "__render_day(garmin_sum_db, graph, datetime.date.today() - datetime.timedelta(days = 6))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "__render_day(garmin_sum_db, graph, datetime.date.today() - datetime.timedelta(days = 7))"
   ]
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "d4f50e87ad7f9cd136d9d3dcf547b8236ee2585f92d0ab7c53dfb80e44e3fae9"
  },
  "kernelspec": {
   "display_name": "Python 3.9.5 64-bit ('.venv')",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.7"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
